package com.example.mytransitiondemo.Drawable;

import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.example.mytransitiondemo.BaseActivity;
import com.example.mytransitiondemo.R;

public class DrawableActivity extends BaseActivity implements View.OnClickListener {


    private AnimationDrawable background;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_drawable);

        findViewById(R.id.start).setOnClickListener(this);

        ImageView iv_arrow = (ImageView) findViewById(R.id.iv_arrow);
        iv_arrow.setBackgroundResource(R.drawable.drawable_anim);
        background = (AnimationDrawable) iv_arrow.getBackground();
    }

    @Override
    public void onClick(View v) {
        background.start();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (background.isRunning()) {
            background.stop();
        }
    }
}
